#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

int main()
{
	int fd1, fd2, fd3, fd4, fd5;

	while (1) {
   	   fd1 = open("/etc/inittab", O_RDONLY);
   	   printf("valid access /etc/inittab 0(read only)\n");
   	   sleep(1);
   	   fd2 = open("/etc/passwd", O_RDONLY);
   	   printf("valid access /etc/passwd 0(read only)\n");
   	   sleep(1);
   	   fd3 = open("/var/log/messages", O_WRONLY);
   	   printf("valid access /var/log/messages 1(write only)\n");
   	   sleep(1);
   	   fd4 = open("/var/www/html/index.html", O_RDWR);
   	   printf("valid access /var/www/html/index.html 2(read & write)\n");
   	   sleep(1);
   	   fd5 = open("/etc/rc.d/rc.sysinit", O_RDWR);
   	   printf("invalid access /etc/rc.d/rc.sysinit 2(read & write)\n");
   	   sleep(1);

   	   close(fd1);
   	   close(fd2);
   	   close(fd3);
   	   close(fd4);
   	   close(fd5);
	}

	return 0;
}
